# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter
import os


class WangyiproPipeline:


    # def open_spider(self,spider):
    #     self.fp=open()
    def process_item(self, item, spider):
        title_name=item['aa']
        if not os.path.exists('网易news'):
            os.mkdir('网易news')
            with open("网易news/"+"qaq["+title_name+"]"+".txt","w",encoding="utf-8") as fp:
                fp.write(item['bb'])
                fp.close()
                print(title_name,'----ok')
        else:
            with open('网易news/'+title_name+'.txt','w',encoding='utf-8') as fp:
                fp.write(item['bb'])
                fp.close()
                print(title_name,'----ok')


        return item
